Zero-check PDH counter and instance lists, add English index lookup#988
Merged
Conversation
dbwiddis
force-pushed
the
pdhutil
branch
5 times, most recently
from
July 14, 2018 17:14
3bbfe7e to
53e5993
Compare
| // Can't allocate 0 memory | ||
| if (pcchCounterListLength.getValue().intValue() < 1 || pcchInstanceListLength.getValue().intValue() < 1) { | ||
| return counters; | ||
| } |
Member
There was a problem hiding this comment.
Is it possible, that only one of the lists has content? I would special case the 0-elements case and replace the memory with a null pointer. From my experience that is the expected usage of the API.
Contributor
Author
There was a problem hiding this comment.
Good point. If it's 0 you can null it and it works; but if it's nonzero you can't null it. I decided to go the route of just setting the "other" value to 0 and not asking for data I won't use.
dbwiddis
force-pushed
the
pdhutil
branch
2 times, most recently
from
July 19, 2018 04:24
d318e62 to
f937b4c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The util methods I submitted in #973 do not handle zero-length results (e.g., no counters or instances) well, throwing an
IllegalArgumentExceptionwhen attempting to instantiateMemory. I've added checks to return sane values.Also I've added a Util method that looks up the counter index from the English name using the registry, to permit easier localization of counter strings.